<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- <meta name="viewport" content="width=414" /> -->
    <!-- <meta name="viewport" content="width=device-width" /> -->
    <!-- <meta name="viewport" content="initial-scale=2" /> -->
    <!-- <meta name="viewport" content="width=500, initial-scale=1" /> -->
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1" /> -->
    <!-- <meta name="viewport" content="minimum-scale=1" /> -->
    <!-- <meta name="viewport" content="maximum-scale=1" /> -->
    <!-- <meta name="viewport" content="maximum-scale=1, minimum-scale=1" /> -->
    <meta name="viewport" content="user-scalable=no" />


    <title>viewport 控制</title>
</head>
<body>
    <div id="result"></div>
    
    <script>
        // console.log('布局视口的宽度为: '+ document.documentElement.clientWidth);
        //获取元素
        let result = document.querySelector("#result");

        setInterval(() => {
            //设置文本
            result.innerHTML = `
                当前布局视口的宽度: ${document.documentElement.clientWidth}<br/>
                当前视觉视口的宽度: ${window.visualViewport.width}
            `
        }, 300)
    </script>
</body>
</html>